package com.thread.start;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Administrator
 *
 * @author jiangbang
 * @date 2016/6/17
 */
public class SleepDemo03 implements Runnable{

    /**
     * 倒计时
     * @param args
     */
    public static void main(String[] args) throws InterruptedException {
        Date endTime = new Date(System.currentTimeMillis()+10*1000);
        long end = endTime.getTime();
        while (true){
            System.out.println(new SimpleDateFormat("mm:ss").format(endTime));
            endTime = new Date(endTime.getTime()-1000);
            Thread.sleep(1000);
            if(end-1000<endTime.getTime()){
                break;
            }
        }
    }

    /**
     * 初始用sleep
     * @param args
     * @throws InterruptedException
     */
    public static void test1(String[] args) throws InterruptedException {
        int num=10;
        while (true){

            Thread.sleep(1000); //暂停
            if(num<=0){
                break;
            }
        }
    }

    @Override
    public void run() {

    }
}
